package io.adrainty.algorithm.leetcode.normal;

/**
 * @author adrainty
 * @version v1.0.0
 * @since 2024/12/23 下午2:23
 */

@SuppressWarnings("unused")
public class Solution122 {

    public int maxProfit(int[] prices) {
        int res = 0;
        int pre = prices[0];
        for (int i = 1; i < prices.length; i++) {
            if (prices[i] > pre) {
                res += prices[i] - pre;
            }
            pre = prices[i];
        }
        return res;
    }
}
